package main

import (
	"fmt"
	"time"
)

func main() {
	c := make(chan int)

	//1、注意这两种写法，入和出
	go func(ch chan<- int, x int) {
		time.Sleep(time.Microsecond)
		ch <- x * x
	}(c, 3)

	done := make(chan struct{})

	go func(ch <-chan int) {
		n := <-ch
		fmt.Println(n)
		done <- struct{}{}
	}(c)

	<-done
	//2、注意，此处没有close通道
	fmt.Println("bye")
}
